package InterviewPractise.JAVAForSQL.Entity;

import org.hibernate.annotations.Entity;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;


/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/20/11
 * Time: 10:04 AM
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table( name ="table1")
public class Table1Entity {

    private Integer id;
    private Date field1;
    private String field2;
    private Date field3;
    private Integer field4;
    private Integer field5;
    private Table2Eneity table2;

    @GenericGenerator(name="genreator" , strategy = "increment")
    @Id
    @Column(name="id" , unique = true , nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }



    public String getField2() {
        return field2;
    }

    public void setField2(String field2) {
        this.field2 = field2;
    }

    public Date getField3() {
        return field3;
    }

    public void setField3(Date field3) {
        this.field3 = field3;
    }

    public Integer getField4() {
        return field4;
    }

    public void setField4(Integer field4) {
        this.field4 = field4;
    }

    public Integer getField5() {
        return field5;
    }

    public void setField5(Integer field5) {
        this.field5 = field5;
    }

    @OneToOne(cascade = CascadeType.ALL , fetch = FetchType.LAZY )
    @JoinColumn(name="field1")
    public Table2Eneity getTable2() {
        return table2;
    }

    public void setTable2(Table2Eneity table2) {
        this.table2 = table2;
    }

}
